package servlet;

import service.impl.StudentServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(urlPatterns = "/Educational/student/deletebyid")
public class DeleteLine extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String stuid = req.getParameter("stuid");
        StudentServiceimpl studentServiceimpl = new  StudentServiceimpl();
        int k = studentServiceimpl.deletestudent(Integer.parseInt(stuid));
        resp.setContentType("text/html;charset= utf-8;");
        PrintWriter writer = resp.getWriter();
        if (k>0){
            writer.println("<script>location.href='/Educational/student/getstudents';alert('删除成功'); </script>");
        }
    }
}
